﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Register Src="~/Views/Lightbox/LightboxManager.ascx" TagName="lightboxmanager" TagPrefix="uc" %>
<%@ Register Src="~/Views/Lightbox/LightboxControl.ascx" TagName="lightboxcontrol" TagPrefix="uc" %>


<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	LIGHTBOXES 
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
<link href="/Content/scroller.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/scroller.js"></script>
<script>
    $(document).ready(function (e) {
        $(".headermenu_item a").eq(3).addClass("active");
        createScoller("imagescroller");
        $("#viewinglightbox").bind("changed", function (e) {
            window.location = "/Lightbox/Index/" + $(this).val();
        });
        $("#selectall").click(function (e) {
            $("#lightboxdetail .chkimg").trigger("check");
        });
        $("#deselectall").click(function (e) {
            $("#lightboxdetail .chkimg").trigger("uncheck");
        });
        $("#removefromlightbox").click(function (e) {
            var lbid = $("#viewinglightbox").attr("value");
            var data = {"lbid" : lbid};
            $("#lightboxdetail .chkimg[checked]").each(function(index){
                data[$(this).attr("id")] = true;
            });
            ajaxquery('<%= Url.Action("RemoveFromLightbox", "Lightbox") %>',data,function(data){ alert(data); location.reload();});
        });
        $("#copytolightbox").click(function (e) {
            var lbid = $("#cmbcopytolightbox").attr("value");
            var data = {"lbid" : lbid};
            $("#lightboxdetail .chkimg[checked]").each(function(index){
                data[$(this).attr("id")] = true;
            });
            ajaxquery('<%= Url.Action("CopyToLightbox", "Lightbox") %>',data,function(data){ alert(data);});
        });
        $("#deletelightbox").click(function (e) {
            var lbid = $("#viewinglightbox").attr("value");
            if (lbid == "") {
                alert("Bạn chưa chọn Lightbox!");
                return;
            }
            var d = "id=" + lbid;
            ajaxquery('<%= Url.Action("DeleteLightbox", "Lightbox") %>', d, function (data) {
                alert(data);
                location.reload();
            });
        });
        $("#createlightbox").click(function (e) {
            $("#lightboxmanagertype").val("create");
            $("#lightboxlabel").text("Tạo Lightbox");
            $("#btnlightboxsubmit").val("Tạo");
            $("#lightboxmanager_form").fadeIn();
            $("#lightboxmanager_form .textbox input").val("");
        });
        $("#renamelightbox").click(function (e) {
            if ($("#viewinglightbox .combobox_selected").text().trim() == "") {
                return false;
            }
            $("#lightboxmanagertype").val("rename");
            $("#lightboxlabel").text("Đổi tên Lightbox");
            $("#txtlightboxname").val($("#viewinglightbox .combobox_selected").text());
            $("#btnlightboxsubmit").val("Đổi tên");
            $("#lightboxmanager_form").fadeIn();
        });
    });

    function lightboxmanagersubmit() {
        var name = $("#txtlightboxname").val();
        var type = $("#lightboxmanagertype").val();
        var id = 0;
        if (type == "rename" && $("#viewinglightbox .combobox_selected").attr("value") != "") {
            id = $("#viewinglightbox").attr("value");
        }
        var data = { "name": name, "type": type, "id": id };
        ajaxquery("<%= Url.Action("CreateOrRenameLightbox", "Lightbox") %>", data, function (data) {
            alert(data);
            location.reload();
        });
        return false;
    }

    function lightboxmanagerreset() {
        $("#lightboxmanager_form").fadeOut();
    }
</script>
</asp:Content>


<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%
    VietImage.Roles.RegisteredUserRole role = (VietImage.Roles.RegisteredUserRole)Session["Role"];
    if (role is VietImage.Roles.CustomerRole)
    {
        //lightboxmanger1.ViewData = ViewData;
        %>
        <uc:lightboxmanager ID="lightboxmanger1" runat="server" />
        <%
    }
    else
    {
%>
<script>
    $(document).ready(function () {
        showPanel('loginpanel');
    });
</script>
<%
    }
 %>

<div id="lightboxcontrol">
<uc:lightboxcontrol ID="lightboxcontrol1" runat="server" />
</div>

</asp:Content>
